import { WinodwCreate } from "@application/ipc/window";
import { defineComponent, ref } from "vue";
import { isNumber } from "@utils/judge";

export default defineComponent({
  setup() {

    let detailId = ref<Nullable<number>>(null);

    async function createDetail() {
      detailId.value = (await WinodwCreate(
        undefined,
        {
          title:'详情',
          route:'/detail'
        }
      )).winId;
    }

    function detailIdRender() {
      return isNumber(detailId.value) ? (
        <span class="glb-red">已创建详情窗口，窗口ID：{detailId.value}</span>
      ) : null;
    }

    return () => (
      <div class="home">
        <span class="home-title">这里是首页</span>
        <br />
        <button onClick={createDetail}>创建详情窗口</button>
        {detailIdRender()}
      </div>
    );
  },
});
